package cn.edu.ctgu.ch1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tiger54910
 * @create 2025/1/31 15:16
 */
@RequestMapping("/words")
@RestController
public class WordsController {
  @Resource private final @Qualifier("measuredDefaultWordsService")WordsService wordsService;

  @Autowired
  public WordsController(@Qualifier("measuredDefaultWordsService") WordsService wordsService) {
    this.wordsService = wordsService;
  }

  @GetMapping("/word-of-the-day")
  public String getWordOfTheDay() {
    return wordsService.getWordOfTheDay();
  }

  @GetMapping("/word-exists")
  public boolean validateWordExists(@RequestParam String word) {
    return wordsService.wordExists(word);
  }
}
